﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CNVP.JShop.UI;
using CNVP.Framework;

namespace CNVP.JShop.Web.Admin.CommonWindows
{
    public partial class SValuePic_Post_Window : AdminPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            rblUpWay.Attributes.Add("onclick", "UpWay()");
        }

        protected void btUp_Click(object sender, EventArgs e)
        {
            if (rblUpWay.SelectedValue == "1")
            {
                if (fileUp.HasFile == false)
                {
                    BasePage.MessageBox("您还没有选择图片！");
                    return;
                }
                else
                {
                    string root = Server.MapPath("../../UploadFile/File/");
                    string fileName = fileUp.PostedFile.FileName;
                    string imgType = fileName.Substring(fileName.LastIndexOf(".") + 1);
                    if (imgType.ToLower() != "jpg" && imgType.ToLower() != "bmp" && imgType.ToLower() != "gif" && imgType.ToLower() != "jpeg" && imgType.ToLower() != "png")
                    {
                        BasePage.MessageBox("上传的图片必须为.jpg或.bmp或.gif或.jpeg或.png！");
                        return;
                    }
                    string newName = "SVPic_" + DateTime.Now.ToString("yyyyMMddhhmmssfff") + "." + imgType;
                    fileUp.PostedFile.SaveAs(root + "\\" + newName);
                    BasePage.CloseWindowReturnValues("../UploadFile/File/" + newName);
                }
            }
            else if (rblUpWay.SelectedValue == "2")
            {
                BasePage.CloseWindowReturnValues(txtWebUrl.Text.Trim());
            }
        }
    }
}